{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "49fcc91a",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Kline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "6fc7a921",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'data_k' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_14352/3031265133.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mday\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata_k\u001b[0m\u001b[1;33m[\u001b[0m \u001b[1;34m'日期'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mv\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata_k\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m[\u001b[0m \u001b[1;34m'开盘价'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'收盘价'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'最低价'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'最高价'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtolist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[0mkline\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mKline\u001b[0m\u001b[1;33m(\u001b[0m \u001b[1;34m'上证指数K线图'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwidth\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;36m1900\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheight\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;36m800\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'data_k' is not defined"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "day = data_k[ '日期'].tolist()\n",
    "\n",
    "v = data_k[[ '开盘价', '收盘价', '最低价', '最高价']].values.tolist()\n",
    "\n",
    "kline = Kline( '上证指数K线图', width= 1900, height= 800)\n",
    "\n",
    "kline.add( '日K',day, v,\n",
    "\n",
    "mark_point=[ 'max'], is_datazoom_show= True)\n",
    "\n",
    "kline.render( './参考案例HTML/上证指数K线图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4cc61053",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'D:\\\\GitHub\\\\vnpy\\\\examples\\\\jupeter\\\\render.html'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Kline\n",
    "\n",
    "\n",
    "data = [\n",
    "    [2320.26, 2320.26, 2287.3, 2362.94],\n",
    "    [2300, 2291.3, 2288.26, 2308.38],\n",
    "    [2295.35, 2346.5, 2295.35, 2345.92],\n",
    "    [2347.22, 2358.98, 2337.35, 2363.8],\n",
    "    [2360.75, 2382.48, 2347.89, 2383.76],\n",
    "    [2383.43, 2385.42, 2371.23, 2391.82],\n",
    "    [2377.41, 2419.02, 2369.57, 2421.15],\n",
    "    [2425.92, 2428.15, 2417.58, 2440.38],\n",
    "    [2411, 2433.13, 2403.3, 2437.42],\n",
    "    [2432.68, 2334.48, 2427.7, 2441.73],\n",
    "    [2430.69, 2418.53, 2394.22, 2433.89],\n",
    "    [2416.62, 2432.4, 2414.4, 2443.03],\n",
    "    [2441.91, 2421.56, 2418.43, 2444.8],\n",
    "    [2420.26, 2382.91, 2373.53, 2427.07],\n",
    "    [2383.49, 2397.18, 2370.61, 2397.94],\n",
    "    [2378.82, 2325.95, 2309.17, 2378.82],\n",
    "    [2322.94, 2314.16, 2308.76, 2330.88],\n",
    "    [2320.62, 2325.82, 2315.01, 2338.78],\n",
    "    [2313.74, 2293.34, 2289.89, 2340.71],\n",
    "    [2297.77, 2313.22, 2292.03, 2324.63],\n",
    "    [2322.32, 2365.59, 2308.92, 2366.16],\n",
    "    [2364.54, 2359.51, 2330.86, 2369.65],\n",
    "    [2332.08, 2273.4, 2259.25, 2333.54],\n",
    "    [2274.81, 2326.31, 2270.1, 2328.14],\n",
    "    [2333.61, 2347.18, 2321.6, 2351.44],\n",
    "    [2340.44, 2324.29, 2304.27, 2352.02],\n",
    "    [2326.42, 2318.61, 2314.59, 2333.67],\n",
    "    [2314.68, 2310.59, 2296.58, 2320.96],\n",
    "    [2309.16, 2286.6, 2264.83, 2333.29],\n",
    "    [2282.17, 2263.97, 2253.25, 2286.33],\n",
    "    [2255.77, 2270.28, 2253.31, 2276.22],\n",
    "]\n",
    "\n",
    "kline=(\n",
    "    Kline()\n",
    "        .add_xaxis([\"2017/7/{}\".format(i + 1) for i in range(31)])\n",
    "        .add_yaxis(\"kline\", data)\n",
    "        .set_global_opts(\n",
    "            yaxis_opts=opts.AxisOpts(is_scale=True),\n",
    "            xaxis_opts=opts.AxisOpts(is_scale=True),\n",
    "            title_opts=opts.TitleOpts(title=\"Kline-基本示例\"),\n",
    "        )\n",
    "    )\n",
    "kline.render()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a774e0a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
